//
//  GoogleTableViewController.m
//  bitcoin
//
//  Created by caiyajun on 2018/6/6.
//  Copyright © 2018年 比特币. All rights reserved.
//

#import "GoogleTableViewController.h"
#import "LoginSafeTableViewController.h"
@interface GoogleTableViewController ()
@property (weak, nonatomic) IBOutlet UIButton *changeCertifyBtn;
@property (weak, nonatomic) IBOutlet UILabel *isTieLabel;

@end

@implementation GoogleTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(closeGoogleSafeAction:) name:@"closeGoogleSafeNoti" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(openGoogleSafeAction:) name:@"openGoogleSafeNoti" object:nil];
    
    UIBarButtonItem *back = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"arrowleft-icon"] style:UIBarButtonItemStylePlain target:self action:@selector(backAction:)];
    self.navigationItem.leftBarButtonItem = back;
    
    [self.changeCertifyBtn setImage:[UIImage imageNamed:@"btmactive-icon"] forState:UIControlStateNormal];
    [self.changeCertifyBtn setImage:[UIImage imageNamed:@"btm-icon"] forState:UIControlStateSelected];
    
    if ([[UserDefaults objectForKey:K_ISGOOGLE] isEqualToString:@"1"]) {
        
        self.changeCertifyBtn.selected=YES;
    }else{
        
        self.changeCertifyBtn.selected=NO;
    }
}
- (void) closeGoogleSafeAction:(NSNotification *)notification{
    
    self.changeCertifyBtn.selected=NO;
    
    
}
- (void) openGoogleSafeAction:(NSNotification *)notification{
    
    self.changeCertifyBtn.selected=YES;
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)backAction:(UIBarButtonItem *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 2;
}
- (IBAction)changeAction {
    if (!self.changeCertifyBtn.selected) {
        [self performSegueWithIdentifier:@"googleOpenSegue" sender:nil];
    }else{
        UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Login" bundle:nil];
        LoginSafeTableViewController *loginSafeCtrl = [sb instantiateViewControllerWithIdentifier:@"LoginSafeTableViewController"];
        loginSafeCtrl.pushType=@"googleCertifyVC";
        [self.navigationController pushViewController:loginSafeCtrl animated:YES];
        
    }
    
    
}

@end
